//
//  UIBarButtonItem+Extension.swift
//  LPZ-DYZB
//
//  Created by 刘培壮 on 2016/11/14.
//  Copyright © 2016年 刘培壮. All rights reserved.
//

import UIKit

extension UIBarButtonItem {

    convenience init(imageName: String, highlightedImageName: String = "", size: CGSize = .zero) {
        let button = UIButton(type: .custom)
        
        button.setImage(UIImage(named:imageName), for: UIControlState())
        if highlightedImageName != "" {
            button.setImage(UIImage(named: highlightedImageName), for: .highlighted)
        }
        if size == .zero {
            button.sizeToFit()
        } else {
            button.lpz_size = size
        }
        self.init(customView: button)
    }
}
